import axios from 'axios'
import apiUrls from 'common/api-urls'
import { contentTypeWww } from 'common/axio-decorate'

export function getLessonFindList(data) {
  return axios.get(`${apiUrls.getLessonFindList}`, {
    params: data
  })
}

export function addLesson(data) {
  return axios.post(apiUrls.addLesson, {
    ...data
  })
}

export function updateLesson(data) {
  return axios.post(apiUrls.updateLesson, {
    ...data
  })
}

export function getLessonById(data) {
  return axios.get(`${apiUrls.getLessonById}/${data.id}`, {
    params: data
  })
}

export function publishLesson(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.post(`${apiUrls.publishLesson}/${data.id}`, data, {
    headers: { 'Content-Type': contentTypeWww }
  })
}

export function unPublishLesson(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.post(`${apiUrls.unPublishLesson}/${data.id}`, data, {
    headers: { 'Content-Type': contentTypeWww }
  })
}

export function deleteLesson(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.delete(`${apiUrls.deleteLesson}?lessonId=${data.lessonId}`)
}
